package com.asset.dispoal.defaultDepartment;

import com.asset.dispoal.defaultDepartment.api.IGbDefaultDepartmentService;
import com.asset.dispoal.defaultDepartment.dto.GbDefaultDepartmentRequest;
import com.asset.dispoal.defaultDepartment.dto.GbDefaultDepartmentResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.controller.BaseController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;

/**
 * 默认部门控制层
 *
 * @author: mhuang
 * @date: 2022-03-18 10:42:26
 */
@RestController
@RequestMapping("gb/defaultDepartment")
@Api(value = "默认部门配置", tags = "默认部门配置")
public class GbDefaultDepartmentController extends BaseController {

    @Autowired
    IGbDefaultDepartmentService gbDefaultDepartmentService;


    @Permission(code = "debtbank:sect")
    @GetMapping(value = "/queryTree")
    @ApiOperation(value = "查询", notes = "查询")
    public Result<List<GbDefaultDepartmentResponse>> queryTree(String companyType) {
        return gbDefaultDepartmentService.queryDefaultDepTree(companyType);
    }

    @PostMapping(value = "/insert")
    @ApiOperation(value = "添加", notes = "添加")
    public Result insert(@RequestBody GbDefaultDepartmentRequest request) {
        return gbDefaultDepartmentService.insert(request);
    }

    @PostMapping(value = "/update")
    @ApiOperation(value = "修改", notes = "修改")
    public Result update(@RequestBody GbDefaultDepartmentRequest request) {
        return gbDefaultDepartmentService.upadte(request);

    }

    @PostMapping(value = "/delete")
    @ApiOperation(value = "删除", notes = "删除")
    public Result delete(@RequestBody String id) {
        return gbDefaultDepartmentService.delete(id);
    }


}